﻿//------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All rights reserved.
//------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Text;

namespace Microsoft.ResourceManagement.Samples.ResourceManagementClient.WSEnumerate
{
    /// <summary>
    /// This class encapsulates a WS-Enumeration EnumerateResponse.
    /// Please read the spec http://www.w3.org/Submission/WS-Enumeration/
    /// 
    /// A client receives this message in response to an EnumerateRequest.
    /// 
    /// A client then uses the EnumerationContext to Pull elements from the server.
    /// </summary>
    [XmlRoot(ElementName = "EnumerateResponse", Namespace = Constants.NamespaceWSEnumeration)]
    public class EnumerateResponse
    {
        private String expires;
        private String enumerationContext;
        private EnumerationDetail enumerationDetail;
        public EnumerateResponse()
        {
            this.Expires = String.Empty;
            this.EnumerationContext = String.Empty;
            this.EnumerationDetail = new EnumerationDetail();
        }

        
        /// <summary>
        /// The server-reported expriation time.
        /// </summary>
        [XmlElement(ElementName = "Expires", Type = typeof(String))]
        public String Expires
        {
            get
            {
                return this.expires;
            }
            set
            {
                this.expires = value;
            }
        }

        
        /// <summary>
        /// This is an opaque string used by the server to identify the enumeration.
        /// Pass this string to all Pull Requests
        /// </summary>
        [XmlElement(ElementName = "EnumerationContext", Type = typeof(String))]
        public String EnumerationContext
        {
            get
            {
                return this.enumerationContext;
            }
            set
            {
                this.enumerationContext = value;
            }
        }

        
        /// <summary>
        /// This is an ILM-specific element used to transmit details about the enumeration context.
        /// </summary>
        // TODO: move to the Resource Management namespace
        [XmlElement(ElementName = "EnumerationDetail", Namespace = Constants.NamespaceWSEnumeration, Type = typeof(EnumerationDetail))]
        public EnumerationDetail EnumerationDetail
        {
            get
            {
                return this.enumerationDetail;
            }
            set
            {
                this.enumerationDetail = value;
            }
        }
    }

    [XmlType(TypeName = "EnumerationDetail")]
    public class EnumerationDetail
    {
        public EnumerationDetail()
        {
            this.Count = 0;
        }
        private Int32 count;
        /// <summary>
        /// The number of objects in the enumeration.
        /// </summary>
        [XmlElement(ElementName = "Count", Namespace = Constants.NamespaceResourceManagement, Type = typeof(Int32))]
        public Int32 Count
        {
            get
            {
                return this.count;
            }
            set
            {
                this.count = value;
            }
        }
    }
}
